<?php
/**
 * Created by PhpStorm.
 * User: wuchao
 * Date: 2020/4/21
 * Time: 10:20
 */
namespace app\api\model;

use \Exception;
use think\facade\Db;
use \think\response\Json;

class OrganizationModel
{
    private static $_table = 'organization'; // 用户表
    private static $_user_address_table = 'user_address'; // 用户地址表
    private static $_dirverTable = 'dirver'; // 司机表
    private static $_dirver_routeTable = 'dirver_route'; // 司机路由表

    /**模糊搜索站点
     * @param array $input
     * @return Json
     */
    public static function SearchSite($input)
    {
        $field = 'id,name,province,city,address,area,detail';
        if($input['province'] && $input['city'] && $input['area']){
            $data = Db::table(self::$_table)->where('admin_id',$input['admin_id'])->where('status',1)->where('province',$input['province'])->where('city',$input['city'])->where('area',$input['area'])->where('type',3)->field($field)->select()->toArray();
        }else{
            if(!empty($input['text'])){//站点内容
                $data = Db::table(self::$_table)->where('admin_id',$input['admin_id'])->where('status',1)->where('type',3)->whereLike('name', '%' . $input['text'] . '%')->field($field)->select()->toArray();
            }else{
                return jsonFail('内容不能为空');
            }
        }
        return jsonSuccess('获取成功',$data);
    }

}